package com.ruoyi.client.controller;

import com.ruoyi.client.service.ClientUserService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.supply.domain.TMember;
import com.ruoyi.supply.service.impl.TMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author huangxiong
 * @date 2025/06/03 20:42
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/client/user")
@Api(tags = "客户端我的模块")
@Slf4j
public class ClientUserMineController extends BaseController  {

    public final ClientUserService clientUserService;

    public final TMemberService tMemberService;



    /**
     * 修改会员管理
     */
    @Log(title = "会员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改会员管理")
    public AjaxResult edit(@RequestBody TMember tMember)
    {
        TMember updateDto = new TMember();
        updateDto.setId(SecurityUtils.getUserId());
        updateDto.setAvatar(tMember.getAvatar());
        updateDto.setUsername(tMember.getUsername());
        updateDto.setPhone(tMember.getPhone());

        return AjaxResult.success(tMemberService.updateTMember(updateDto));
    }


    @GetMapping("/mine/push/{infoType}")
    @ApiOperation("我的发布")
    public TableDataInfo myPush(@PathVariable("infoType") String infoType){
        startPage();
        List<Object> list = clientUserService.selectMyPush(infoType);
        return getDataTable(list);
    }

    @GetMapping("/mine/order/{type}")
    @ApiOperation("我的订单")
    public TableDataInfo myOrder(@PathVariable("type") String type,
                                 @RequestParam(value = "extra",required = false)String param,
                                 @RequestParam(value = "status",required = false)String status){
        startPage();
        List list = clientUserService.selectMyOrder(type,param,status);
        return getDataTable(list);
    }



}

